# To change this template, choose Tools | Templates
# and open the template in the editor.

MANDALA_FNAME = "../imgs/environment/mandala.png"
#this is a class with animated rings that rotate around
ROT_SPDS = [0.03,-0.02,0.01]
ZOOMS = [1.25,2.0,3.25]
ALPHAS = [40,128,211]

ROT_SPD_UPDATETIME = 1

BGCOLOR = (40,40,40)


import hexconfig
from hexconfig import *
CENTER = getPosFromHexLoc((0,0,0))

import pygame

class BackGround():

    def __init__(self):
        self.mandalas = []
        for i in range(3):
            img = pygame.image.load(MANDALA_FNAME)
            img = pygame.transform.scale(img, (int(img.get_width()*ZOOMS[i]),int(img.get_height()*ZOOMS[i])))

            img.set_colorkey((255,255,255))
            img.set_alpha(ALPHAS[i])

            self.mandalas.append(img)
        self.rots = [0.0,0.0,0.0]
        self.rotTimer = 0
    def update(self,etime):
        self.rotTimer+=etime
        if self.rotTimer>ROT_SPD_UPDATETIME:
            self.rotTimer -=ROT_SPD_UPDATETIME
            for i in range(3):
                self.rots[i]+=ROT_SPDS[i]*etime
                self.rots[i] = 360.0+self.rots[i] if self.rots[i]<0.0 else self.rots[i]
                self.rots[i] = self.rots[i]-360.0 if self.rots[i]>360.0 else self.rots[i]


    
    def draw(self,surf):
        DARK_COLORS = [(98,12,13)]
        #surf.fill(BGCOLOR)
        rotate = pygame.transform.rotate
        for i in range(2):
            if random.random()<0.2:
                x = random.randrange(100,400)
                if random.random()<0.5:
                    x = -x
                y = random.randrange(100,300)
                if random.random()<0.5:
                    y = -y
                pygame.draw.circle(surf,random.choice(DARK_COLORS),(x,y),random.randrange(12,36))
            rotSurf = pygame.transform.rotate(self.mandalas[i],self.rots[i])
            surf.blit(rotSurf,rotSurf.get_rect(center = CENTER).topleft)
        